const app = getApp()
let {
  baseUrl,
  commonUpdate,
  commonUpload
} = app.globalData
const state = [{
    name: "常用功能",
    id: 1,
    arr: [
      /*  {
         name: "我的评价",
         img: "/assets/image/user/我的评价.png",
         type: 1
       },
       {
         name: "就诊人管理",
         img: "/assets/image/user/添加联系人.png",
         type: 2
       }, */
     /*  {
        name: "我的延期",
        img: "/assets/image/user/添加联系人.png",
        type: 3
      }, */
      /*   {
          name: "服务报告",
          img: "/assets/image/user/添加联系人.png",
          type: 3
        }, */
      {
        name: "账户安全",
        img: "/assets/image/user/账户安全.png",
        type: 4
      },
      {
        name: "项目申请",
        img: "/assets/image/user/账户安全.png",
        type: 5

      },
    ],
    actions: [{
      name: ''
    }],
    showPhone: false
  },

]
Page({

  /**
   * 页面的初始数据
   */
  data: {
    baseUrl,
    commonUpdate,
    commonUpload,
    userInfo: {},
    state,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    /* this.getUserInfo() */
  },
  /**
   * 生命周期函数--监听页面显示
   */

  onShow() {
    this.getUserInfo()
    if (typeof this.getTabBar === "function" &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 1
      })
    }
  },

  async getUserInfo() {
    console.log(app)
    this.setData({
      userInfo: wx.getStorageSync('userInfo'),
    }, () => {

    })
    console.log(this.data.userInfo)
  },

  onClickLeft() {
    wx.navigateTo({
      url: '/pages/user/visitorList/index',
    })
  },

  onClickRight() {
    wx.navigateTo({
      url: '/pages/user/satisfaction/list/index',
    })
  },

  onClickBottom(e) {
    const type = e.currentTarget.dataset.type
    switch (type) {
      case 1:
        wx.navigateTo({
          url: '/pages/myEvaluation/index',
        })
        break;
      case 2:
        wx.navigateTo({
          url: '/pages/searchPatient/index',
        })
        break;
      case 3:
        wx.navigateTo({
          url: '/pagesDoctor/myExtension/index',
        })
        break;
      case 4:
        wx.navigateTo({
          url: '/pagesDoctor/accountSecurity/index',
        })
        break;
      case 5:
        wx.navigateTo({
          url: '/pagesDoctor/qualificationApplication/index',
        })
        break;
      default:
        break;
    }
  },

  handleGetPhone(e) {
    const tel = '123456789'
    this.setData({
      showPhone: true,
      'actions[0].name': `${tel}`
    })
  },
  onClose() {
    this.setData({
      showPhone: false
    });
  },
  onEdit() {
    const item = this.data.userInfo
    wx.navigateTo({
      url: '/pagesDoctor/userEdite/index?item=' + JSON.stringify(item),
    })
  },




  onClickExit() {
    wx.clearStorage()
    wx.reLaunch({
      url: '/pagesDoctor/doctorLogin/index',
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})